<?php
/*
 * [JINYUN!] (C)2001-2099 Jinyunweb.com
 * This is NOT a freeware, use is subject to license terms
 * $Id: 2017-12-13 03:39:35 apple $
*/
//账户设置
defined('BY_JYA') or exit('error');
$_RQ['op']=$_RQ['op']?$_RQ['op']:'base';
$return=array();
if($_RQ['op']=='base'){
	$item=pdo_get('core_accounts',array('uniacid'=>$_SESSION['uniacid']));
	$kefuset=uni_setting('kefuset');
	$kefuset['kefutype_h5']=$kefuset['kefutype_h5']?:'0';
	$kefuset['kefutype_app']=$kefuset['kefutype_app']?:'0';
	$item=array_merge($item,$kefuset);
	$item['hdps']=json_decode($item['hdps'],true);
	if(empty($item['hdps'])){
		$item['hdps']=array(
			array('picurl'=>'../core/resource/images/nopic.jpg'),
		);
	}
	$item['apps']=json_decode($item['apps'],true);
	if(empty($item['apps'])){
		$item['apps']=array(
			array('title'=>'在线商城','icon'=>'icon-gouwuchexuanzhong','is_show'=>1,'action'=>'jy_weishop/index/','desc'=>'在线购买我们的服务/产品！'),
			array('title'=>'其他服务','icon'=>'icon-xiaochengxu','is_show'=>1,'action'=>'jy_weishop/index/','desc'=>'更多服务，站长还没有完善'),
		);
	}
	$item['plugins']=json_decode($item['plugins'],true);
	$item['webapps']=json_decode($item['webapps'],true);
	if(empty($item['webapps'])){
		$item['webapps']=$plugins;
	}
	$item['h5game']=json_decode($item['h5game'],true);
	$navs=array(
			array('title'=>'产品列表','action'=>'core/home.goods/','url'=>custom_url('core/home.goods/')),
			array('title'=>'新闻动态','action'=>'core/article.list/','url'=>custom_url('core/article.list/')),
	);
	$item['navs']=$item['navs']?json_decode($item['navs'],true):$navs;
	$item['mobilenavs']=$item['mobilenavs']?json_decode($item['mobilenavs'],true):array();
	$item['demonavs'] = $navs;
	$return['item'] = $item;
	$return['item']['anlis']=json_decode($return['item']['anlis'],true);
	$return['item']['links']=json_decode($return['item']['links'],true);
	$return['item']['naddress']=json_decode($return['item']['naddress'],true);
	$return['item']['cip']=json_decode($return['item']['cip'],true);
	$return['item']['time_box']=$return['item']['time_box']?json_decode($return['item']['time_box'],true):array();
	if(empty($return['item']['desc'])){
		pdo_update('core_accounts',array('desc'=>'小主很懒，未填写站点描述！'),array('uniacid'=>$_SESSION['uniacid']));
	}
	$id=uni_setting('default_mobile_web');
	if($item['isdiy'] && $id){
		$return['item']['siteurl']=custom_url('core/welcome/',true);	
	}else{
		$return['item']['siteurl']=custom_url('core/home.welcome/',true);
	}
	$return['item']['abouturl']=custom_url('core/home.abouts/',true);
	$htmls=array(
			'type'=>'edit',
			'post'=>'basepost',
			'desc'=>'基本信息',
			'edit_tab'=>true,
			'edits'=>array(
				array(
					'title'=>'基本信息',
					'list'=>array(
								array('type'=>'copy','title'=>'站点链接地址','name'=>'siteurl', 'help'=>'' ),
								array('type'=>'ewm','title'=>'站点二维码','name'=>'siteurl', 'help'=>'' ),
								array('type'=>'switch','title'=>'启用DIY微官网','name'=>'isdiy', 'help'=>'（<red>在没有设置好DIY微官网的时候，千万别开启</red>）。启用后，访问站点时将直接访问:默认微官网或默认PC页面' ),
								array('type'=>'string','title'=>'站点名称','name'=>'title', 'help'=>'' ),
								array('type'=>'string','title'=>'站点描述','name'=>'desc', 'help'=>'' ),
								array('type'=>'image','title'=>'站点图标','name'=>'logo', 'help'=>'' ),
								array('type'=>'image','title'=>'站点二维码','name'=>'ewm', 'help'=>'可填写微信公众号二维码，用于微官网关注扫码！' ),
								array('type'=>'image','title'=>'小程序二维码','name'=>'wxapp_ewm', 'help'=>'可填写小程序二维码，用于小程序产品宣传！' ),
								array('type'=>'image','title'=>'宣传二维码','name'=>'xiu_ewm', 'help'=>'可填写H5场景秀二维码，用于产品宣传！' ),
								array('type'=>'string','title'=>'宣传URL','name'=>'xiu_url', 'help'=>'可填写H5场景秀URL，用于产品宣传！' ),
								array('type'=>'string','title'=>'底部技术支持','name'=>'js_support'),
								array('type'=>'image','title'=>'底部技术支持图片','name'=>'js_supportimg'),
								array('type'=>'text','title'=>'第三方统计代码','name'=>'code' ),
					)
				),
				array(
					'title'=>'界面UI配色',
					'list'=>array(
						array('type'=>'color_pool','title'=>'选择配色方案','name'=>'syscolor','help'=>''),
						array('type'=>'colorpicker','title'=>'站点颜色','name'=>'syscolor','help'=>'自定义系统颜色系，默认： #18bc9c'),
						array('type'=>'phone_tpl','name'=>'syscolor'),
					)
				),
				array(
					'title'=>'业务特点',
					'list'=>array(
								array('type'=>'switch','title'=>'是否关闭显示','name'=>'noapps', 'help'=>'' ),
								array(
									'type'=>'array',
									'name'=>'apps',
									'add_tip'=>'添加一个业务',
										'list'=>array(
											array('type'=>'string','name'=>'title','title'=>'业务标题'),
											array('type'=>'icon','name'=>'icon','from'=>'jinyunicon','title'=>'产品ICO'),
											array('type'=>'string','name'=>'action','title'=>'业务链接'),
											array('type'=>'string','name'=>'desc','title'=>'业务描述'),
											array('type'=>'radio','name'=>'is_show','title'=>'是否显示','options'=>'is_shows'),
										),
										'details'=>array(
											array('type'=>'string','name'=>'title','title'=>'业务标题'),
											array('type'=>'icon','name'=>'icon','from'=>'jinyunicon','title'=>'业务ICO','help'=>''),
											array('type'=>'link','name'=>'action','from'=>'action','title'=>'业务链接'),
											array('type'=>'string','name'=>'desc','title'=>'业务描述'),
											array('type'=>'switch','name'=>'is_show','title'=>'是否显示'),
										)
								),
					)
				),
				array(
					'title'=>'业务产品',
					'list'=>array(
								array('type'=>'switch','title'=>'是否关闭显示','name'=>'noplugins', 'help'=>'' ),
								array(
									'type'=>'array',
									'name'=>'plugins',
									'add_tip'=>'添加一个产品',
										'list'=>array(
											array('type'=>'string','name'=>'title','title'=>'产品标题'),
											array('type'=>'icon','name'=>'icon','from'=>'jinyunicon','title'=>'产品ICO'),
											array('type'=>'string','name'=>'action','title'=>'产品链接'),
											array('type'=>'string','name'=>'desc','title'=>'产品描述'),
											array('type'=>'radio','name'=>'is_show','title'=>'是否显示','options'=>'is_shows'),
										),
										'details'=>array(
											array('type'=>'string','name'=>'title','title'=>'产品标题'),
											array('type'=>'icon','name'=>'icon','from'=>'jinyunicon','title'=>'产品ICO','help'=>''),
											array('type'=>'link','name'=>'action','from'=>'action','title'=>'产品链接'),
											array('type'=>'text','name'=>'desc','title'=>'产品描述'),
											array('type'=>'switch','name'=>'is_show','title'=>'是否显示'),
										)
								),
					)
				),
				array(
					'title'=>'幻灯片设置',
					'list'=>array(
								array('type'=>'image','name'=>'banner380','title'=>'其他页面顶部横幅','help'=>'建议尺寸：1920*380,如果PC端图片模糊，请联系管理员，加大附件图片保存尺寸！'),
								array(
									'type'=>'array',
									'name'=>'hdps',
									'add_tip'=>'添加一个幻灯片',
										'list'=>array(
											array('type'=>'image','name'=>'picurl','title'=>'幻灯片图片'),
											array('type'=>'string','name'=>'url','title'=>'幻灯片链接'),
											
										),
										'details'=>array(
											array('type'=>'image','name'=>'picurl','title'=>'幻灯片图片','help'=>'建议尺寸：1920*520,如果PC端图片模糊，请联系管理员，加大附件图片保存尺寸！'),
											array('type'=>'string','name'=>'url','title'=>'幻灯片链接'),
											
										)
								),
					)
				),
				array(
					'title'=>'顶部导航',
					'list'=>array(						
							array('type'=>'updemo','name'=>'navs','demo'=>'demonavs','title'=>'重置导航','help'=>'不知道添加什么导航？重置默认的一下试试！'),
								array(
									'type'=>'array',
									'name'=>'navs',
									'add_tip'=>'添加一个前端顶部导航(【注意】添加后，系统首页只显示这里的菜单！)',
										'list'=>array(
											array('type'=>'string','name'=>'title','title'=>'导航名称'),
											array('type'=>'string','name'=>'action','title'=>'导航链接'),
											array('type'=>'icon','name'=>'icon','title'=>'导航icon'),
											
										),
										'details'=>array(
											array('type'=>'icon','name'=>'icon','title'=>'导航icon','help'=>''),
											array('type'=>'string','name'=>'title','title'=>'导航名称'),
											array('type'=>'link','from'=>'action','name'=>'action','title'=>'导航链接','help'=>'这里可以直接填action,也可以直接填网址！'),
											
										)
								),
					)
				),
				array(
					'title'=>'手机导航',
					'list'=>array(						
								array(
									'type'=>'array',
									'name'=>'mobilenavs',
									'add_tip'=>'添加一个前端顶部导航！',
										'list'=>array(
											array('type'=>'string','name'=>'title','title'=>'导航名称'),
											array('type'=>'string','name'=>'action','title'=>'导航链接'),
											array('type'=>'icon','from'=>'jinyunicon','name'=>'icon','title'=>'导航icon'),
											
										),
										'details'=>array(
											array('type'=>'icon','from'=>'jinyunicon','name'=>'icon','title'=>'导航icon','help'=>''),
											array('type'=>'string','name'=>'title','title'=>'导航名称'),
											array('type'=>'link','from'=>'action','name'=>'action','title'=>'导航链接','help'=>'这里可以直接填action,也可以直接填网址！'),
											
										)
								),
					)
				),
				array(
					'title'=>'友情链接',
					'list'=>array(
								array(
									'type'=>'array',
									'name'=>'links',
									'add_tip'=>'添加一个友情链接',
										'list'=>array(
											array('type'=>'image','name'=>'picurl','title'=>'图片'),
											array('type'=>'string','name'=>'title','title'=>'标题'),
											array('type'=>'string','name'=>'url','title'=>'链接'),
											
										),
										'details'=>array(
											array('type'=>'image','name'=>'picurl','title'=>'图片','help'=>''),
											array('type'=>'string','name'=>'title','title'=>'标题'),
											array('type'=>'string','name'=>'url','title'=>'链接','help'=>'要http://或https://前缀'),
											
										)
								),
					)
				),
				array(
					'title'=>'关于我们',
					'list'=>array(
								array('type'=>'select','title'=>'站点新闻分类','name'=>'newsgroupid','options'=>'groups' ),
								array('type'=>'ewm','title'=>'站点二维码','name'=>'abouturl', 'help'=>'' ),
								array('type'=>'string','title'=>'联系人','name'=>'lxr' ),
								array('type'=>'string','title'=>'联系电话','name'=>'phone' ),
								array('type'=>'string','title'=>'QQ','name'=>'qq' ),
								array('type'=>'string','title'=>'邮箱','name'=>'mail' ),
								array('type'=>'string','title'=>'公司名称','name'=>'cname' ),
								array('type'=>'string','title'=>'ICP备案号','name'=>'icp' ),
								array('type'=>'string','title'=>'互联网信息服务ICP经营许可证','name'=>'cip.cip','help'=>'申请地址：https://tsm.miit.gov.cn/dxxzsp/'),
								array('type'=>'string','title'=>'互联网信息服务ICP经营许可证链接地址','name'=>'cip.cipurl','help'=>'申请地址：https://tsm.miit.gov.cn/dxxzsp/'),
								array('type'=>'string','title'=>'增值电信业务EDI经营许可证','name'=>'cip.edi','help'=>'申请地址：https://tsm.miit.gov.cn/dxxzsp/'),
								array('type'=>'string','title'=>'增值电信业务EDI经营许可证链接地址','name'=>'cip.ediurl','help'=>'申请地址：https://tsm.miit.gov.cn/dxxzsp/'),
								array('type'=>'string','title'=>'公网安备号','name'=>'cip.gongan','help'=>'写全：例如：京公网安备 11010102002019号 '),
								array('type'=>'string','title'=>'公网安备号URL','name'=>'cip.gonganurl' ),
								array('type'=>'text','title'=>'关于我们','name'=>'about' ),
								array('type'=>'text','title'=>'企业文化','name'=>'culture' ),
								array('type'=>'text','title'=>'加入我们','name'=>'join' ),
								array('type'=>'string','title'=>'详细地址','name'=>'address' ),
								array('type'=>'lat_lng','title'=>'地理位置','name'=>'naddress' ),
					)
				),
				array(
					'title'=>'联系我们',
					'list'=>array(
								array('type'=>'switch','title'=>'关闭漂浮客服？','name'=>'nokefu'),
								array('type'=>'image','title'=>'客服漂浮图标','name'=>'kefuicon'),
								array('type'=>'radio','title'=>'H5端客服类型','name'=>'kefutype_h5','options'=>'kefutypes'),
								array('type'=>'radio','title'=>'小程序端客服类型','name'=>'kefutype_app','options'=>'kefutypesapp','help'=>'如果是小程序客服：必须先去微信官方开启客服功能，并添加客服；添加后，客服员工，请搜索《<red>客服小助手</red>》小程序，然后进入接收信息！</br>【<red>小程序客服收不到消息</red>】？移步：小程序官方后台--开发--开发设置--消息推送（关闭掉就可以了）'),
								array('type'=>'string','title'=>'第三方客服链接','name'=>'kflink','help'=>'必须是http,htpps开头的完整链接'),
								array('type'=>'link','from'=>'action','title'=>'客服系统短链接','name'=>'appkflink','help'=>'必须是系统短链，格式比如类似：jy_kefu/home/，适用：产品详情左下角，手机端客服按钮'),					
								array('type'=>'string','title'=>'微信客服账户','name'=>'kf_account','help'=>'格式：客服账户@公众号账户，例如：kefumimi@wechatMP；微信公众号后台，客服功能--添加客服--获取客服账户'),
								array('type'=>'image','title'=>'企业微信客服二维码','name'=>'weikfewm','help'=>'用于非小程序环境下，客户扫码进入咨询！'),
								array('type'=>'image','title'=>'顾问客服二维码','name'=>'guwenkfewm','help'=>'开通教程：微信公众号后台--添加功能插件--对话能力--创建顾问--下载二维码;</br>顾问后台进入方法：搜索小程序“服务号小助手”'),
								array('type'=>'string','title'=>'企业微信客服ID','name'=>'weikfid','help'=>'用于小程序端直接访问，企业微信客服ID（获取教程，移步：https://work.weixin.qq.com/ 客户联系--互动服务--联系我--新建联系方式--小程序客服--配置ID（如已新建了小程序客服，可以在《使用引导》中查看）。<br>格式如下：70ae2799dc6874e6f65929e378762388）！<br>配置流程如下：https://open.work.weixin.qq.com/api/doc/90000/90136/92376'),
					)
				),
			)
		);
	$return['groups']=pdo_getall('core_account_article_fenlei',array('uniacid'=>$_SESSION['uniacid']),array('id','title'));
	$return['kefutypes']=array('第三方客服链接','微信客服','系统客服短接','企业微信客服二维码','顾问客服二维码');
	$return['kefutypesapp']=array('小程序客服','第三方客服链接','系统客服短接','企业微信客服');
	$return['is_shows']=array('0'=>'不显示','1'=>'显示');
	$return['htmls']=$htmls;
	exi($return);
}
if($_RQ['op']=='basepost'){
	$postdata=get_postdata();
	if($_SESSION['user']['type']<3 && !$_SESSION['isfounder']){
		exi('您没有权限设置！','error');
	}
	$id=uni_setting('default_mobile_web');
	if($postdata['isdiy'] && !$id){
		exi('您还没设置默认微站，不可启用！','error','website.mobile_web');
	}
	foreach($postdata['navs'] as &$nv){
		$nv['url']=custom_url($nv['action']);
	}
	$data=array(
		'title'=>trim($postdata['title']),
		'logo'=>trim($postdata['logo']),
		'desc'=>trim($postdata['desc']),
		'ewm'=>trim($postdata['ewm']),
		'isdiy'=>intval($postdata['isdiy']),
		'wxapp_ewm'=>trim($postdata['wxapp_ewm']),
		'xiu_ewm'=>trim($postdata['xiu_ewm']),
		'xiu_url'=>trim($postdata['xiu_url']),
		'noapps'=>intval($postdata['noapps']),
		'noplugins'=>intval($postdata['noplugins']),
		'hdps'=>ijson_encode($postdata['hdps']),
		'apps'=>ijson_encode($postdata['apps']),
		'h5game'=>ijson_encode($postdata['h5game']),
		'webapps'=>ijson_encode($postdata['webapps']),
		'plugins'=>ijson_encode($postdata['plugins']),
		'anlis'=>ijson_encode($postdata['anlis']),
		'links'=>ijson_encode($postdata['links']),
		'cip'=>ijson_encode($postdata['cip']),
		'kflink'=>trim($postdata['kflink']),
		'lxr'=>trim($postdata['lxr']),
		'phone'=>trim($postdata['phone']),
		'qq'=>trim($postdata['qq']),
		'mail'=>trim($postdata['mail']),
		'cname'=>trim($postdata['cname']),
		'icp'=>trim($postdata['icp']),
		'about'=>trim($postdata['about']),
		'culture'=>trim($postdata['culture']),
		'join'=>trim($postdata['join']),
		'code'=>trim($postdata['code']),
		'address'=>trim($postdata['address']),
		'naddress'=>ijson_encode($postdata['naddress']),
		'newsgroupid'=>intval($postdata['newsgroupid']),
		'syscolor'=>trim($postdata['syscolor']),
		'js_support'=>trim($postdata['js_support']),
		'js_supportimg'=>trim($postdata['js_supportimg']),
		'banner380'=>trim($postdata['banner380']),
		'navs'=>ijson_encode($postdata['navs']),
		'mobilenavs'=>ijson_encode($postdata['mobilenavs']),
	);
	$_SESSION['account']['title']=$data['title'];
	$_SESSION['account']['logo']=$data['logo'];
	$kefuset=uni_setting('kefuset');
	$qrticket=$kefuset['qrticket'];
	$keyid='sitekf_account';
	if($postdata['kefutype_h5']==1 && (empty($qrticket) || $postdata['kf_account']!=$kefuset['kf_account'])){
			$title = '站点-客服de二维码';
			$getqrdata=array(
				'keyid'=>$keyid,
			);
			$getqrdata = ijson_encode($getqrdata);
			$qr = cfc('account')->get_qr(2,'core',$getqrdata,30,$title,$keyid);	
			$kefuset['qrticket']=$qr['ticket'];
			$kefuset['kf_accountimg']=$qr['file'];
	}
	$kefuset['nokefu']=$postdata['nokefu'];
	$kefuset['kefuicon']=$postdata['kefuicon'];
	$kefuset['kefutype_h5']=$postdata['kefutype_h5'];
	$kefuset['kefutype_app']=$postdata['kefutype_app'];
	$kefuset['kflink']=$postdata['kflink'];
	$kefuset['appkflink']=$postdata['appkflink'];
	$kefuset['kf_account']=$postdata['kf_account'];
	$kefuset['weikfewm']=$postdata['weikfewm'];
	$kefuset['guwenkfewm']=$postdata['guwenkfewm'];
	$kefuset['weikfid']=$postdata['weikfid'];
	uni_setting('kefuset',$kefuset);
	pdo_update('core_accounts',$data,array('uniacid'=>$_SESSION['uniacid']));
	exi('设置成功！');
}
?>